<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" style="display: flex; flex-wrap: nowrap;"
             :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="反馈时间" prop="f1204" style="display: flex; flex-wrap: nowrap;">
        <el-date-picker style="width: 14vw"
                        v-model="queryParams.f1204"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择反馈时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="反馈状态" prop="f1205" style="display: flex; flex-wrap: nowrap;">
        <el-select v-model="queryParams.f1205" placeholder="请选择反馈状态" clearable style="width: 14vw;" >
          <el-option
            v-for="dict in dict.type.feedback_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item style="margin: 0 0 0 30vw;">
        <el-button type="primary" icon="el-icon-search"  @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh"  @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          style="background-color: black; color: white; width: 10vw;"
          @click="updateStatus"
        >标记为已处理
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          style="background-color: black; color: white; width: 10vw;"
          @click="handleReply"
        >批量回复
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="T12List" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="f1202" />
      <el-table-column label="联系电话" align="center" prop="f0604" />
      <el-table-column label="所属公司" align="center" prop="f0302" />
      <el-table-column label="反馈上传时间" align="center" prop="f1204" width="180"/>
      <el-table-column label="回复人" align="center" prop="f0103">
        <template slot-scope="scope">
          <span v-if="scope.row.f1205 !== 0 && scope.row.f0103">{{ scope.row.f0103 }}</span>
          <span v-else>暂未回复</span>
        </template>
      </el-table-column>
      <el-table-column label="回复时间" align="center" prop="f1206" width="180">
        <template slot-scope="scope">
          <span v-if="scope.row.f1205 !== 0 && scope.row.f1206">{{ parseTime(scope.row.f1206, '{y}-{m}-{d}') }}</span>
          <span v-else>暂未回复</span>
        </template>
      </el-table-column>

      <el-table-column label="反馈状态" align="center" prop="f1205">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.feedback_status" :value="scope.row.f1205"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="toReplyScreen(scope.row)"
          >查看详细</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 批量回复对话框 -->
    <el-dialog :title="title" :visible.sync="openReply" width="33vw"  :appendToBody="true">
        回复信息：
        <el-input
        type="textarea"
        :rows="8"
        placeholder="请输入内容"
        v-model="message">
        </el-input>
      <div style="margin: 2vw 0 0 9vw">
        <el-row>
          <el-button @click="Cancel">取消</el-button>
          <el-button type="primary" style="margin: 0 0 0 3vw" @click="updateReply">回复</el-button>
        </el-row>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listT12} from "@/api/T12/T12";
import Request from '@/utils/request'
export default {
  name: "T12",
  dicts: ['feedback_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 信息反馈表格数据
      T12List: [],
      openReply:false,
      title: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        f1204: null,
        f1205: null,
      },
      //批量回复的信息
      message:''
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询信息反馈列表 */
    getList() {
      this.loading = true;
      listT12(this.queryParams).then(response => {
        this.T12List = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.f1201)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 批量回复按钮 弹窗*/
    handleReply() {
      if(this.ids===null||this.ids.length===0)
      {
        this.$modal.msgError("请选择需要回复的信息");
        return
      }
      this.openReply=true;
      this.title='批量回复'
    },
    Cancel(){
      this.message=null;
      this.openReply=false;
    },
    /**批量回复*/
    updateReply(){
      //调用接口
      Request.put('/T12/T12/bulkResponses',
        {f1201s:this.ids,f1207:this.message}).then(response => {
        this.$modal.msgSuccess("回复成功");
        this.getList();
      })
      this.ids=[];
      this.message=null;
      this.openReply=null;
    },
    /** 批量更改未已处理 */
    updateStatus(){
      Request.put('/T12/T12/updateStatusProcessed',
        {f1201s:this.ids}).then(response=>{
        this.$modal.msgSuccess("修改成功");
        this.getList();
      })
    },
    //详细界面
    toReplyScreen(row){
      this.$router.push({ name: 'replyScreen' , params: { id: row.f1201 }});
    }
  }
};
</script>
<style>
.el-tag-common-green {
  background-color: #E8FFEA; /* 浅绿色背景 */
  border-color: #98e69e; /* 深一些的绿色边框 */
  color: #66ffcc; /* 更亮的绿色字体 */
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1;
  border-width: 1px;
  border-style: solid;
  border-radius: 4px;
  box-sizing: border-box;
  white-space: nowrap;
}

.el-tag-green {
  /* 假设您希望.el-tag-green与.el-tag-common完全一致，或者您可以指定不同的绿色 */
  background-color: #e0f2f1; /* 浅绿色背景 */
  border-color: #b2d7d2; /* 深一些的绿色边框 */
  color: #4fdc4f; /* 更亮的绿色字体 */
  /* 如果需要特别指定.el-tag-green独有的样式，可以在这里添加 */
}

/* 红 */
.el-tag-common-red {
  background-color: #ffebee; /* 浅红色背景 */
  border-color: #d32f2f; /* 深红色边框 */
  color: #b71c1c; /* 深红色字体 */
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1;
  border-width: 1px;
  border-style: solid;
  border-radius: 4px;
  box-sizing: border-box;
  white-space: nowrap;
}
.el-tag-red {
  /* 重写.el-tag-common的样式以使用红色主题 */
  background-color: #ffebee; /* 浅红色背景 */
  border-color: #d32f2f; /* 深红色边框 */
  color: #b71c1c; /* 深红色字体 */
  /* 如果需要特别指定.el-tag-green独有的样式，可以在这里添加 */
}
/* 灰色 */
/* 灰色调的基础标签样式 */
.el-tag-common-grey {
  background-color: #e0e0e0; /* 灰色背景 */
  border-color: #9e9e9e; /* 灰色边框 */
  color: #424242; /* 深灰色字体 */
  /* 其他样式保持不变 */
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1;
  border-width: 1px;
  border-style: solid;
  border-radius: 4px;
  box-sizing: border-box;
  white-space: nowrap;
}

/* 特定于灰色标签的样式，继承自 .el-tag-common-grey */
.el-tag-grey {
  /* 如果需要，可以在这里添加额外的灰色主题样式 */
  /* 例如，如果你想要更深的灰色，可以覆盖背景色和边框色 */
  background-color: #bdbdbd; /* 更深的灰色背景 */
  border-color: #616161; /* 更深的灰色边框 */
}
</style>
